package com.horoscope.astrology.zodiac.signs.free.adapter

import android.content.Context
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.horoscope.astrology.zodiac.signs.free.R
import com.horoscope.astrology.zodiac.signs.free.fragment.BirthdayFragment
import com.horoscope.astrology.zodiac.signs.free.fragment.LoadFragment

class MainPageFragmentAdapter(private val mContext: Context, fm: FragmentManager) :
    FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    //    private var mNameFragment: NameFragment? = null
//    private var mGenderFragment: GenderFragment? = null
    private var mBirthdayFragment: BirthdayFragment? = null
    //    private var mBornFragment: BornTimeFragment? = null
//    private var mRelationshipFragment: RelationshipFragment? = null
    private var mLoadFragment: LoadFragment? = null


//    fun setNameFragment(fragment: NameFragment) {
//        mNameFragment = fragment
//    }
//
//    fun setGenderFragment(fragment: GenderFragment) {
//        mGenderFragment = fragment
//    }

    fun setBirthdayFragment(fragment: BirthdayFragment) {
        mBirthdayFragment = fragment
    }

//    fun setBornFragment(fragment: BornTimeFragment) {
//        mBornFragment = fragment
//    }
//
//    fun setRelationshipFragment(fragment: RelationshipFragment) {
//        mRelationshipFragment = fragment
//    }

    fun setLoadFragment(fragment: LoadFragment) {
        mLoadFragment = fragment
    }


    override fun getCount(): Int = mTitleResIds.size

    override fun getItem(position: Int): Fragment {
        return when (position) {
//            0 -> return mNameFragment
//            1 -> return mGenderFragment
            0 -> mBirthdayFragment!!
//            3 -> return mBornFragment
//            4 -> return mRelationshipFragment
            1 -> mLoadFragment!!

            else -> Fragment()
        }
    }

    override fun getPageTitle(position: Int): CharSequence? =
        mContext.getString(mTitleResIds[position])

    companion object {
        private val mTitleResIds = intArrayOf(
//            R.string.fragment_name_title,
//            R.string.fragment_gender_title,
//            R.string.fragment_gender_title,
//            R.string.fragment_gender_title,
            R.string.fragment_gender_title,
            R.string.fragment_birthday_title
        )
    }

}